package com.songlanyun.modules.coupon.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.songlanyun.modules.coupon.entity.CouponEntity;
import com.songlanyun.modules.shop.entity.ShopEntity;
import com.songlanyun.modules.shop.model.vo.ShopSlimVO;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.Query;

import com.songlanyun.modules.coupon.dao.CouponShopDao;
import com.songlanyun.modules.coupon.entity.CouponShopEntity;
import com.songlanyun.modules.coupon.service.CouponShopService;


@Service("couponShopService")
public class CouponShopServiceImpl extends ServiceImpl<CouponShopDao, CouponShopEntity> implements CouponShopService {

    @Override
    public CouponShopEntity create(CouponShopEntity entity) {
        return null;
    }

    @Override
    public CouponShopEntity modify(CouponShopEntity entity) {
        return null;
    }

    @Override
    public void remove(Long id) {

    }

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<CouponShopEntity> page = this.page(
                new Query<CouponShopEntity>().getPage(params),
                new QueryWrapper<CouponShopEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<ShopSlimVO> loadAdaptShops(Long couponId) {
        return this.baseMapper.loadAdaptShops(couponId);
    }

    @Override
    public List<Long> loadAdaptShopIds(Long couponId) {
        return this.baseMapper.loadAdaptShopIds(couponId);
    }

    @Override
    public void batchSet(CouponEntity couponEntity, List<CouponShopEntity> couponShopEntities) {
        this.baseMapper.delete(new LambdaQueryWrapper<CouponShopEntity>().eq(CouponShopEntity::getCouponId,couponEntity.getId()));
        this.saveBatch(couponShopEntities);
    }

}
